package com.heg.api.control;

import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.heg.api.service.SmsModuleService;
import com.heg.api.tool.RequestModel;
import com.heg.api.tool.ResponseCode;
import com.heg.api.tool.ResponseModel;

/**
 * 短信模块api接口
 * @author 邓绪招
 * @time 2016-04-23
 * @version 1.0.1
 */
@RequestMapping(value = "/hegapi/sms")
@Controller("smsModuleAction")
public class SmsModuleAction {
	
	@Resource
	private SmsModuleService smsModuleService;
	
	/**
	 * 验证码获取api -- 用户注册
	 * @param params
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/obtainregseccodes", method = RequestMethod.POST)
	public ResponseModel send_sms_secCodes(@RequestBody String params){
		Map<String, Object> paramsMaps = RequestModel.getRequestParams(params);
		String telnumber = paramsMaps.get("telnumber").toString();
		Map<String, Object> retMaps = smsModuleService.sec_codes_obtainreg(telnumber);
		if(retMaps != null && retMaps.size() > 0){
			return new ResponseModel(ResponseCode.REQUEST_SUCCESS, "success", retMaps);
		} else {
			return new ResponseModel(ResponseCode.REQUEST_SMS_OBTAIN_FAILURE, "error", "获取验证码失败!");
		}
	}

}
